import { createApp } from 'vue'
import App from './App.vue'
import './styles/global.css'

/**
 * 创建Vue应用实例
 * 适配Web环境，模拟微信小程序API
 */
function initApp() {
  const app = createApp(App)
  
  // 全局配置
  app.config.globalProperties.$showToast = (title, icon = 'none') => {
    uni.showToast({
      title,
      icon,
      duration: 2000
    })
  }
  
  // 全局配置导航跳转方法
  app.config.globalProperties.$navigateTo = (url) => {
    uni.navigateTo({ url })
  }
  
  app.config.globalProperties.$redirectTo = (url) => {
    uni.redirectTo({ url })
  }
  
  // 挂载应用到DOM
  app.mount('#app')
  
  return app
}

// 初始化应用
initApp()